﻿using Microsoft.Phone.Shell;
using System;
using System.ComponentModel;

namespace SMARTMobile.WinPhone
{
    public class PhoneApplicationBarMenuItem : IApplicationBarMenuItem, INotifyPropertyChanged
    {
        #region Fields

        private bool _isEnabled;
        private string _text;

        #endregion

        #region Constructors

        public PhoneApplicationBarMenuItem(string text, bool isEnabled)
        {
            this._text = text;
            this._isEnabled = isEnabled;
        }

        public PhoneApplicationBarMenuItem(string text)
            : this(text, true)
        {
        }

        #endregion

        public event PropertyChangedEventHandler PropertyChanged;

        #region Properties

        public bool IsEnabled
        {
            get { return _isEnabled; }
            set { _isEnabled = value; NotifyPropertyChanged("IsEnabled"); }
        }

        public string Text
        {
            get { return _text; }
            set { _text = value; NotifyPropertyChanged("Text"); }
        }

        public event EventHandler Click;

        #endregion

        private void NotifyPropertyChanged(string propertyname)
        {
            if (null != PropertyChanged) PropertyChanged(this, new PropertyChangedEventArgs(propertyname));
        }
    }
}
